# class Foo(object):
#     def __init__(self,name,age,email):
#         self.name = name
#         self.age = age
#         self.email = email
#
# obj = Foo('alex',19,'xxxx@qq.com')
# print(obj)
# print(obj.name)
# print(obj.age)
# print(obj.email)
# val = obj.__dict__ # 去对象中找到所有变量并将其转换为字典
# print(val)


# class Foo(object):
#     def __add__(self, other):
#         return 123
#
#
# obj1 = Foo()
# obj2 = Foo()
# val = obj1 + obj2
# print(val)
#
#
# try:
#     int('123')
#     raise Exception('阿萨大大是阿斯蒂') # 代码中主动抛出异常
# except Exception as e:
#     print(e)

# class Foo(object):
#
#     def __init__(self, age):
#         self.age = age
#
#     def display(self):
#         print(self.age)
#
# data_list = [Foo(8), Foo(9)]
# for item in data_list:
#     print(item.age, item.display())

# class Base(object):
#     def __init__(self, a1):
#         self.a1 = a1
#
#     def f2(self, arg):
#         print(self.a1, arg)
#
# class Foo(Base):
#     def f2(self, arg):
#         print('666')
#
# obj_list = [Base(1), Foo(2), Foo(3)]
# for obj in obj_list:
#     obj.f2(1)
# 1,1
# 666
# 666

# class StarkConfig(object):
#
#     def __init__(self,num):
#         self.num = num
#
#     def changelist(self,request):
#         print(self.num,request)
#
# class RoleConfig(StarkConfig):
#
#     def changelist(self,request):
#         print('666')
#
# config_obj_list = [StarkConfig(1),StarkConfig(2),RoleConfig(3)]
# for item in config_obj_list:
#     print(item.num)

# 1,    2,     3

# class StarkConfig(object):
#
#     def __init__(self,num):
#         self.num = num
#
#     def changelist(self,request):
#         print(self.num,request)
#
# class RoleConfig(StarkConfig):
#     pass
#
# config_obj_list = [StarkConfig(1),StarkConfig(2),RoleConfig(3)]
# for item in config_obj_list:
#     item.changelist(168)

# 1,168    2,168       3,168


# class StarkConfig(object):
#
#     def __init__(self,num):
#         self.num = num
#
#     def changelist(self,request):
#         print(self.num,request)
#
# class RoleConfig(StarkConfig):
#
#     def changelist(self,request):
#         print(666,self.num)
#
# config_obj_list = [StarkConfig(1),StarkConfig(2),RoleConfig(3)]
# for item in config_obj_list:
#     item.changelist(168)
# 1,168  3,168   666,3

# class StarkConfig(object):
#
#     def __init__(self,num):
#         self.num = num
#
#     def changelist(self,request):
#         print(self.num,request)
#
#     def run(self):
#         self.changelist(999)
#
# class RoleConfig(StarkConfig):
#
#     def changelist(self,request):
#         print(666,self.num)
#
# config_obj_list = [StarkConfig(1),StarkConfig(2),RoleConfig(3)]
# config_obj_list[1].run()
# config_obj_list[2].run()
# 2,999       666,3


# class StarkConfig(object):
#     def __init__(self,num):
#         self.num = num
#     def changelist(self,request):
#         print(self.num,request)
#     def run(self):
#         self.changelist(999)
#
# class RoleConfig(StarkConfig):
#     def changelist(self,request):
#         print(666,self.num)
#
# class AdminSite(object):
#     def __init__(self):
#         self._registry = {}
#     def register(self,k,v):
#         self._registry[k] = v
#
# site = AdminSite()
# print(len(site._registry))          #0
# site.register('range',666)
# site.register('shilei',438)
# print(len(site._registry))          #2
#
# site.register('lyd',StarkConfig(19))
# site.register('yjl',StarkConfig(20))
# site.register('fgz',RoleConfig(33))
#
# print(len(site._registry))          #5
# print(site._registry)               #{'range': 666, 'shilei': 438, 'lyd': <__main__.StarkConfig object at 0x000002BFA3C817F0>, 'yjl': <__main__.StarkConfig object at 0x000002BFA3C81828>, 'fgz': <__main__.RoleConfig object at 0x000002BFA3C81860>}


# class StarkConfig(object):
#     def __init__(self,num):
#         self.num = num
#     def changelist(self,request):
#         print(self.num,request)
#     def run(self):
#         self.changelist(999)
#
# class RoleConfig(StarkConfig):
#     def changelist(self,request):
#         print(666,self.num)
#
# class AdminSite(object):
#     def __init__(self):
#         self._registry = {}
#     def register(self,k,v):
#         self._registry[k] = v
#
# site = AdminSite()
# site.register('lyd',StarkConfig(19))
# site.register('yjl',StarkConfig(20))
# site.register('fgz',RoleConfig(33))
# print(len(site._registry))   #3
#
# for k,row in site._registry.items():
#     row.changelist(5)
# 3   19,5  20,5   666,33

class StarkConfig(object):

    def __init__(self,num):
        self.num = num

    def changelist(self,request):
        print(self.num,request)

    def run(self):
        self.changelist(999)

class RoleConfig(StarkConfig):

    def changelist(self,request):
        print(666,self.num)

class AdminSite(object):
    def __init__(self):
        self._registry = {}

    def register(self,k,v):
        self._registry[k] = v

site = AdminSite()
site.register('lyd',StarkConfig(19))
site.register('yjl',StarkConfig(20))
site.register('fgz',RoleConfig(33))
print(len(site._registry)) # 3

for k,row in site._registry.items():
    row.run()







